package util

import "math/rand"

const (
	NUMERIC = "0123456789"
	ALPHA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	ALNUM = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

/**
 * 生成随机字符串
 * @author sweeter 2022.01.06
 * @return string
 */
func Random(n int, mode string) string {
	var letters = []byte(mode)

	result := make([]byte, n)
	for i := range result {
		result[i] = letters[rand.Intn(len(letters))]
	}
	return string(result)
}